%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                         %
%                          NeQuick-G - Test Code                          %
%                                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%DESCRIPTION
%This short code is meant to show how to use the NeQuick-G function. The
%data were taken from the reference [1] test cases in Annex E.
%
%Reference: "Ionospheric Correction Algorithm for Galileo Single Frequency Users"
%Link: https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galileo_Ionospheric_Model.pdf
%
%---------------------------- Pre-Settings --------------------------------

clear all; clc;

%Add Folders' Paths
addpath(genpath('./Geometr'));
addpath(genpath('./Ionosphere'));
addpath(genpath('./tables'));
addpath(genpath('./TEC'));

%-------------------------- Data Preparation ------------------------------

%Time Data
data.mth   = 4;  %Month [mth]
data.UT    = 4;  %Time  [UTC]

%NeQuick-G Data Extraction of MODIP and F2/Fm3 Coeff.s Tables
[data.stModip, data.F2, data.Fm3] = DataExtract(data.mth);

%Broadcasted NeQuick-G Az Coeff.s (High Solar Activity)
data.a0 =   236.831641;
data.a1 =    -0.39362878;
data.a2 =     0.00402826613;

%Galileo L1-Frequency [Hz]
data.f      = 1575.42e+06;
%Receiver Data
data.RX_h   =          78.11e-3;   %Altitude  [km]
data.RX_lat =            82.49;    %Latitude  [deg]
data.RX_lon = wrapTo180(297.66);   %Longitude [deg]
%Transmitter Data
data.TX_h   =    19953735.00e-3;    %Altitude  [km]
data.TX_lat =            35.85;     %Latitude  [deg]
data.TX_lon = wrapTo180(140.68);    %Longitude [deg]

%Test Case STEC [STECU]
STEC_real   = 37.81;

%-------------------------- NeQuick-G Routine -----------------------------


[TEC, ~, ~] = NeQuickG(data.RX_h, data.RX_lat, data.RX_lon,...
                       data.TX_h, data.TX_lat, data.TX_lon,...
                       data, data.f)
